#include <iostream>
#include <math.h>
#include "../../Course/watch.h"
#include <vector>


using namespace Course;
	double ifaculty(double n){
		double sum = 1;
		for (double i = n; i > 0; i--){
 			sum *= i;
		}
		return sum;
	}
	double rfaculty(double n){
		return n * (n-1 > 0 ? rfaculty(n-1) : 1);
	}

int main(){
	double MAX = 20;
	int LOOPS = 1000000;
	double s1, s2 = s1 = 0;
	Course::Watch  w, wStartEnd;
	Course::microseconds t0,t1,t2,t3;

	wStartEnd.restart();
	std::cout.precision(3);
	std::cout.setf(ios::fixed);
	
	w.restart();
	for (int i = 0; i< LOOPS; i++){
		s1 = ifaculty(MAX);
	}
	t0=w.elapsedUs();
	
	w.restart();
	for (int i = 0; i< LOOPS; i++){
		s2 = rfaculty(MAX);
	}
	t1=w.elapsedUs();

	cout << "Iterative: " << (float) t0.count()/LOOPS << endl << "Recursive: " << (float) t1.count()/LOOPS  << endl;
	cout <<  s1 << endl << s2<< endl;
	cin.get();
}
